home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1997 April
/
EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso
/
EARCD
/
comm
/
bbs
/
Hydra11.lha
/
HBBS
/
Developer
/
Examples
/
ConfigFiles
/
configs.c
next >
Wrap
Text File
|
1996-07-15
|
1KB
|
59 lines
// (C) 1996 Hydra/TSN/LSD
// example of reading items from a config file..
// last updated: 15/07/1996
/* Here's an example config file:
--( CUT HERE )------------------------
FrEd=A string ;skjjshdjskjksjk
num=83634
list_1=fred
list_2=sid
list_3=moocow
bool=YES
; bool=NO
; bool=ON
; bool=OFF
; bool=TRUE
; bool=FALSE
--( CUT HERE )------------------------
*/
void LoadCFG( void )
{
struct CfgFileData *DeviceCFG;
V_ERROR error=TYPE_NONE;
UBYTE *filename="Progdir:Test.CFG";
VTYPE_STRING mystring=NULL; // ALWAYS INITILISE VARIABLES that you pass to HBBS_GetSetting to
VTYPE_STRINGLIST mylist=NULL; // NULL or 0 otherwise you can expect a system crash!
VTYPE_BIGNUM mynum=0;
VTYPE_BOOL mybool=FALSE;
if (DeviceCFG=HBBS_LoadConfig(filename,LCFG_NONE)))
{
HBBS_GetSetting(DeviceCFG,(void *)&mystring,VTYPE_STRING ,"fred",OPT_SINGLE);
HBBS_GetSetting(DeviceCFG,(void *)&mynum ,VTYPE_BIGNUM ,"num" ,OPT_SINGLE);
HBBS_GetSetting(DeviceCFG,(void *)&mylist ,VTYPE_STRINGLIST,"list",OPT_MULTI);
HBBS_GetSetting(DeviceCFG,(void *)&mybool ,VTYPE_BOOL ,"bool",OPT_SINGLE);
HBBS_FlushConfig(DeviceCFG);
}
/*
you can now do stuff with the variables that have been loaded from
the config file as you would with any other variable
*/
// Don't forgetting to free them after use though
FreeStrList(mylist);
FreeStr(mystring);
}